{% extends "admin/base.html" %}
{% load i18n %}
{% load static simpletags %}

{% block title %}{% translate '定时任务' %}{% endblock %}

{% block content %}

<div class="container">
    <div class="el-row">
        <div class="el-col el-col-12">  <!--右侧-->
            <h2>定时任务</h2>
            <script type="text/javascript" src="{% static '/cron/langs/zh-CN.js'' %}?_={% get_version %}"></script>
            <script type="text/javascript" src="{% static '/cron/cron-expression-input.js'' %}?_={% get_version %}"></script>
            <script type="text/javascript" src="{% static '/cron/index.js'' %}?_={% get_version %}"></script>
            <link rel="stylesheet" href="{% static '/cron/index.css' %}?_={% get_version %}">
            <div id="cron-box">
                <select id="id_task_type" name="task_type" disabled>
                    {%for item in task_type_list%}
                    <option {% if item.0 ==  cron_task_obj.task_type %}selected="selected"{% endif %} value="{{item.0}}">{{item.1}}</option>
                    {%endfor%}
            </select>
                <table id="cron-table">
                    <thead>
                        <tr>
                            <th>持续时间(分钟)</th>
                            <th>提前提醒(分钟)</th>
                            <th>开始时间</th>
                            <th>操作</th>
                        <tr>
                    </thead>
                    <tbody id="cron-table-tbody">
                        {% for item in cron_task_as_list %}
                        <tr class="cron-item">
                            <td class="cron-duration">
                                <input class="cron-duration-value" type="text" value="{{item.duration}}">
                            </td>
                            <td class="cron-advance">
                                <input class="cron-advance-value" type="text" value="{{item.advance}}">
                            </td>
                            <td class="cron-value">
                                <cron-expression-input
                                height="34px" width="600px" color="d58512"
                                required="false" hotValidate="true"
                                value="{{item.cron}}"
                                ></cron-expression-input>
                            </td>
                            <td class="cron-opt">
                                <button class="el-button stop-submit el-button--danger el-button--small" type="button" onclick="deleteCronItem(this)"> <i class="el-icon-delete"></i> </button>
                            </td>
                        </tr>
                        {% endfor %}
                    </tbody>
                </table>
              <button class="el-button el-button--primary el-button--small" type="button" style="margin-top: 20px; float: left;" onclick="addCronItem()"> <i class="el-icon-plus"></i> <span>{% trans 'Add' %}</span></button>

              <form action="/madmin/samap/edit_crontask/" method="post" onsubmit="crontaskSubmitFun(this)" style="margin-top: 20px; margin-left: 10px; float: left;">
                {% csrf_token %}
                <input id="id_cron_id" name="cronid" type="text" value="{{cron_task_obj.id}}" hidden>
                <div class="el-col el-col-12" hidden>定时任务</div>
                <div class="el-col el-col-12" hidden><input type="text" name="cron_task" value="" readonly="readonly" id="id_cron_task" value="{{cron_task_obj.cron_task}}"></div>
                <button class="el-button el-button--success el-button--small" type="submit"> <i class="el-icon-circle-check"></i> <span>{% trans 'Save' %}</span></button>
            </form>
            </div>

        </div>   <!--右侧-->
    </div>
</div>

{% endblock %}